import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int m = Integer.parseInt(input[0]);
        int n = Integer.parseInt(input[1]);
        int k = Integer.parseInt(input[2]);
        for (int i = 1; i <= k; i++) {
            int[] arr = new int[n];
            for (int j = 0; j < n; j++) {
                arr[j] = sc.nextInt();
            }
            System.out.println(isValid(arr,m,n)?"YES":"NO");
        }
        sc.close();
    }


    private static boolean isValid(int[] sequence, int maxSize, int n){
        Stack<Integer> stack = new Stack<>();
        int currentNum = 1;
        int index = 0;
        for(int num : sequence){
            while(currentNum <= num){
                stack.push(currentNum);
                currentNum++;
                if(stack.size() > maxSize){
                    return false;
                }
            }
            if (!stack.isEmpty()&&stack.peek() == num){
                stack.pop();
                index++;
            }else {
                return false;
            }
        }
        return index == n;
    }













    public static void main2(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        Queue<Integer> queue = new LinkedList<>();
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        for (int i = 1; i <= x; i++) {
            queue.offer(i);
        }
        StringBuilder result = new StringBuilder();
        int count = 1;
        while (!queue.isEmpty()) {
            int temp = queue.poll();
            if(count == y){
                result.append(temp).append(" ");
                count=1;
            }else{
                queue.offer(temp);
                count++;
            }
        }
        if(result.length()>0){
            result.setLength(result.length()-1);
        }
        System.out.println(result);
    }
















    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int x = Integer.parseInt(input[0]);
        Queue<Integer> queueA = new LinkedList<>();
        Queue<Integer> queueB = new LinkedList<>();
        for (int i = 1; i <= x; i++) {
            int num = Integer.parseInt(input[i]);
            if (num % 2 ==0 ){
                queueB.offer(num);
            }else{
                queueA.offer(num);
            }
        }
        StringBuilder result = new StringBuilder();
        while (!queueA.isEmpty() || !queueB.isEmpty()) {
            if (!queueA.isEmpty()){
                result.append(queueA.poll()).append(" ");
            }
            if (!queueA.isEmpty()){
                result.append(queueA.poll()).append(" ");
            }
            if (!queueB.isEmpty()){
                result.append(queueB.poll()).append(" ");
            }
        }
        if (result.length() > 0){
            result.setLength(result.length() - 1);
        }
        System.out.println(result);
        }
    }